#pragma once
#include "afxcmn.h"
#include "BuddyList.h"
#include "AccCore.h"    // AIMCC main header
#include "resource.h"
#include "vcclr.h"
#include <map>
#include <string> //can't use char* since i need to compare string contents, not addresses
using namespace AIMCC;


// CBuddyListDlg dialog

class CBuddyListDlg : public CDialog
{
	DECLARE_DYNAMIC(CBuddyListDlg)

public:
	CBuddyListDlg(CWnd* pParent, IAccSession* S);   // standard constructor
	virtual ~CBuddyListDlg();
	void addBuddy(xp_str name, xp_str grp, xp_int state);
	void loadBuddyList();
	afx_msg void OnBnClickRefresh();

// Dialog Data
	enum { IDD = IDD_BUDDYLIST_DLG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support	
	virtual BOOL OnInitDialog();
	DECLARE_MESSAGE_MAP()
private:
	CTreeCtrl m_display;	//the main tree view
	CButton m_refresh;
	std::map<std::wstring,HTREEITEM> m_groups;		//hash structure to find if group name is already listed
	int m_grpIndex;
	void getBuddies(IAccGroup* grp);
	CComPtr<IAccBuddyList> m_bL;	//the buddy list object
	CComPtr<IAccSession> m_session;
	CImageList m_imageList;
	afx_msg void OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult);
	gcroot<ProfileWrapper::ProfileWrapper^> m_profileWrap;
};
